<?php
/**
 * Created by PhpStorm.
 * User: shenyvlin
 * Date: 2019/2/26
 * Time: 15:27
 * 会员验证规则
 */
namespace app\api\validate;
use think\validate;
class Members extends Validate{
    protected $rule = [
        'mobile' => 'require|length:11',
        'code' => 'require|length:4,6',
        'realname' => 'require',
        'birthday' => 'require',
        'address' => 'require',
        'email' => 'require|email',
        'idcard'=> 'require|length:18',
        'sex'=>'require|[0,1,2]',
        'code'=> 'require|length:4',
    ];

    protected $message = [
        'mobile.require' => '请输入手机号',
        'mobile.length' => '手机号格式错误',
        'code.require' => '请输入短信验证码',
        'code.length' => '短信验证码错误',
        'realname.require' => '请输入姓名',
        'birthday.require' => '请输入生日',
        'address.require' => '请输入家庭住址',
        'email.require' => '请输入邮箱',
        'email.email' => '邮箱格式错误',
        'idcard.require' => '请输入身份证号',
        'idcard.length' => '身份证号格式有误',
        'sex.require' => '请选择性别',
    ];

    // 验证场景重定义
    protected $scene = [
        'login'  =>  ['mobile','code'],
        'base' => ['realname','birthday','address','email'],
        'updateUserInfo'=>['mobile', 'idcard', 'sex', 'realname'],
    ];

}
